<?php

require_once './library/Row.php';
require_once './application/models/Tables/Dashboard.php';
require_once './application/models/Tables/Droits.php';

class ObjectDashboard
{

    private $_idDashboard;
    private $_moduleDashboard;
    private $_description;
    private $_url;
    private $img;
    private $_refresh;
    private $_nbUtilisateur;
    private $_auteur;
    private $_email;

    public function ObjectDashboard($idDashboard, $moduleDashboard, $description, $url, $refresh, $img, $auteur, $email, $nbUser=0)
    {
        $this->_idDashboard = $idDashboard;
        $this->_moduleDashboard = $moduleDashboard;
        $this->_description = $description;
        $this->_url = $url;
        $this->_img = $img;
        $this->_refresh = $refresh;
        $this->_nbUtilisateur = $nbUser;
        $this->_auteur = $auteur;
        $this->_email = $email;
    }

    public function getIdDashboard()
    {
        return $this->_idDashboard;
    }

    public function setIdDashboard($idDashboard)
    {
        $this->_idDashboard = $idDashboard;
    }

    public function getModuleDashboard()
    {
        return $this->_moduleDashboard;
    }

    public function setModuleDashboard($moduleDashboard)
    {
        $this->_moduleDashboard = $moduleDashboard;
    }

    public function getDescription()
    {
        return $this->_description;
    }

    public function setDescription($description)
    {
        $this->_description = $description;
    }

    public function getUrl()
    {
        return $this->_url;
    }

    public function setUrl($url)
    {
        $this->_url = $url;
    }

    public function getRefresh()
    {
        return $this->_refresh;
    }

    public function setRefresh($refresh)
    {
        $this->_refresh = $refresh;
    }

    public function getImg()
    {
        return $this->_img;
    }

    public function setImg($img)
    {
        $this->_img = $img;
    }

    public function getNbUtilisateur()
    {
        return $this->_nbUtilisateur;
    }

    public function setNbUtilisateur($nbUtilisateur)
    {
        $this->_nbUtilisateur = $nbUtilisateur;
    }

    public function getAuteur()
    {
        return $this->_auteur;
    }

    public function setAuteur($auteur)
    {
        $this->_auteur = $auteur;
    }

    public function getEmail()
    {
        return $this->_email;
    }

    public function setEmail($email)
    {
        $this->_email = $email;
    }

    public static function listeDashboard($id)
    {
        $table = new TableDashboard();
        $rowset = $table->getListeDashboardModule();
        $lst1 = array();
        $lst2 = array();
        $i = 0;
        $j = 0;
        foreach ($rowset as $row)
        {
            if ($row->IdUtilisateur != $id)
            {
                $lst1[$i++] = new ObjectDashboard($row->IdDashboard, $row->ModuleDashboard, $row->Description, $row->Url, $row->Refresh, $row->Img, $row->Auteur, $row->Email, $row->NbUtilisateur);
            } else
            {
                $lst2[$j++] = new ObjectDashboard($row->IdDashboard, $row->ModuleDashboard, $row->Description, $row->Url, $row->Refresh, $row->Img, $row->Auteur, $row->Email, $row->NbUtilisateur);
            }
        }
        return array($lst1, $lst2);
    }

    public static function listeDashboardByUser($idUser)
    {
        $table = new TableDashboard();
        $rowset = $table->getListeDashboardModuleByUser($idUser);
        //print_r($rowset);
        $lst = array();
        $i = 0;
        $j = 0;
        foreach ($rowset as $row)
        {
            $lst[$i++] = new ObjectDashboard($row->IdDashboard, $row->ModuleDashboard, $row->Description, $row->Url, $row->Refresh, $row->Img, $row->Auteur, $row->Email);
        }
        return $lst;
    }

}
?>
